<br>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title><?php echo $title; ?></title>
</head>

<body>

<script>
<?php
$D=0;
foreach($jawaban as $data){
	$D++;
}
echo "var jumlah = ".$D.";\n";
?>
function check(){
	jum = 0;
	jum_2 = 0;
    for(i=0;i<=jumlah;i++){
        id 	 = "check_jawaban"+i;
		
        td1 = "k1"+i;
        td2 = "k2"+i;
        td3 = "k3"+i;
		
        if(document.getElementById(id).checked){
            document.getElementById(td1).style.backgroundColor = "lightblue";
            document.getElementById(td2).style.backgroundColor = "lightblue";
            document.getElementById(td3).style.backgroundColor = "lightblue";
			jum = jum + 1;
			
			//document.getElementById("skor"+i).value = '';
        }else {
            document.getElementById(td1).style.backgroundColor = "white";
            document.getElementById(td2).style.backgroundColor = "white";
            document.getElementById(td3).style.backgroundColor = "white";
        }
    }
}
</script>

<?php
function check_list($check){
	foreach($check['check_jawaban'] as $value){
		?>
		<script>
		var i = <?php echo $value ?>;
		id_2  = "check_jawaban"+i;
		
		td1 = "k1"+i;
		td2 = "k2"+i;
		td3 = "k3"+i;
		
		document.getElementById(td1).style.backgroundColor = "lightgreen";
		document.getElementById(td2).style.backgroundColor = "lightgreen";
		document.getElementById(td3).style.backgroundColor = "lightgreen";
		document.getElementById(id_2).checked = true;
		</script>
		<?php
	}
}

$options_ngram = array('' => "N-Gram");
	for($i=1; $i<=10; $i++)
	{
        $options_ngram[$i] = $i.' kata';
	}
?>
<div id="container">
	<h1>Selamat datang di perhitungan manual Algoritma <?php echo $title; ?>!</h1>

	<div id="body">
		<?php echo form_open(base_url().'main/'.$title); ?>
		<table class="table table-bordered table-hover table-striped tablesorter">
		<tr>
			<td>No</td>
			<td>Jawaban</td>
			<td>Action</td>
		</tr>
		<?php
		$no=0;
		foreach($jawaban as $data){
		?>
		<tr>
			<tr>
			<td id="k1<?php echo$no; ?>"><?php echo$no+1; ?></td>
			<td id="k2<?php echo$no; ?>"><?php echo$data['kalimat']; ?></td>
			<td id="k3<?php echo$no; ?>">
			<input type="checkbox" onclick="check()" value="<?php echo$no; ?>" id="check_jawaban<?php echo$no; ?>" name="check_jawaban[<?php echo$no; ?>]">
			<input type="hidden" name="data_jawaban<?php echo$no; ?>" value="<?php echo$data['kalimat']; ?>">
			</td>
			</tr>
		</tr>
		<?php
		$no++;
		}
		?>
		<table>
		<br>
		<div class="col-lg-1">
		<?php
			$data_submit = array('name' => 'proses_submit', 'class' => 'btn btn-primary', 'value' => 'Proses', 'style' => 'width:83px');
			echo form_submit($data_submit);
		?>
		</div>
		<div class="col-lg-2">
			<?php
			echo form_dropdown('ngram', $options_ngram, $ngram, 'class="form-control" style="width:165px" onchange="this.form.submit()" data-toggle="tooltip" data-placement="bottom" title="N-Gram"');
			?> 				
		</div>
		<?php
		if($kalimat){
			if($hasil_proses){
				?>
				<br>
				<br>
				<table class="table table-bordered table-hover table-striped tablesorter">
				<tr>
					<td>No</td>
					<td>Kalimat</td>
					<td>Hasil</td>
				</tr>
				<?php
				$no = 0;
				foreach($kalimat['check_jawaban'] as $id){ ?>
				<tr>
					<td><?php echo$no+1; ?></td>
					<td><?php echo$kalimat['jawaban_siswa'][$id]; ?></td>
					<td><?php
					if($hasil_proses[$id]!=null){
						print_r($hasil_proses[$id]);
					}else{
						echo '<span class="text-danger">Kalimat <i>"'.$kalimat['jawaban_siswa'][$id].'"</i> bermasalah</span>';
					}
					?></td>
				</tr>
				<?php
				$no++;
				} ?>
				</table>
				<?php
			}
			
			check_list($kalimat);
		}
		echo form_close();
		?>
	</div>
	<br>
	<p class="footer"><a href='<?php echo base_url()."main"; ?>'>Home</a> Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>

</body>
</html>